package org.artifact.core.plugin.jedis;

import cn.hutool.db.nosql.redis.RedisDS;
import cn.hutool.setting.Setting;
import org.artifact.core.lang.MapPlus;
import redis.clients.jedis.Jedis;

import org.artifact.core.lang.IPlugin;
import org.artifact.core.lang.IServer;

import java.util.Map;

/**
 * @author : SandKing
 * @CreateDate : 2020/3/14 19:02
 * @Description ：Please describe this document
 */
public class JedisPlugin implements IPlugin {

    private RedisDS redisDS;

    @Override
    public boolean start() {
        Map config = IServer.me().getContext().getConfig();
        Map jedis = MapPlus.get("plugins.jedis",config);
        Setting setting = new Setting();

        jedis.forEach((k,v)->{
            setting.put(k.toString(),v.toString());
        });


        redisDS = new RedisDS(setting,null);
        return true;
    }

    @Override
    public boolean stop() {
        return true;
    }
    
    public Jedis getJedis() {
    	return redisDS.getJedis();
    }
}
